/**********************************************************
 * AuctionServiceDelegator.java.java 
 * Created by Ashutosh
 * Last modified Date: Sep 18, 2008 10:54:13 AM by Ashutosh
 * Revision: <svn revision #> 
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.delegator;

import static com.printeverywhere.util.AttributeConstants.CLOSING_SESSION;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.printeverywhere.dto.Items;
import com.printeverywhere.util.HibernateUtil;

/**
 * The Class AuctionServiceDelegator.
 */
public class AuctionServiceDelegator {
	
	/** The log. */
	private static Logger log = Logger.getLogger(AuctionServiceDelegator.class);
	
	/**
	 * Save auction sell.
	 * 
	 * @param items the items
	 * 
	 * @throws HibernateException the hibernate exception
	 */
	public static void saveAuctionSell(Items items) throws HibernateException {
		if(log.isInfoEnabled()){
			log.info("Called saveAuctionSell method".intern());
		}
		Session session = HibernateUtil.getSession();
		Transaction transaction = null;
		try {
			transaction = session.beginTransaction();
			session.saveOrUpdate(items);
			transaction.commit();
		} catch (RuntimeException e) {
			log.error("Got exception when Save Auction Sell ".intern());
			if (transaction != null)
				transaction.rollback();
			throw e;
		} finally {
			if(log.isInfoEnabled()){
				log.info(CLOSING_SESSION);
			}
			session.flush();
			session.close();
		}
	}
}